package com.heima.controller;


import com.heima.pojo.dto.UserDto;
import com.heima.pojo.dto.UserSearchDto;
import com.heima.pojo.vo.UserSearchVo;
import com.heima.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ljk
 * @since 2024-10-20
 */
@RestController
@RequestMapping("/api/user-service/user")
@Api(tags = "人员相关接口")
@Slf4j
@RequiredArgsConstructor
public class UserController {
    private final UserService userService;

    @GetMapping("/search")
    @ApiOperation("人员搜索")
    public UserSearchVo pageQuery(UserSearchDto userSearchDto){
        return userService.pageQuery(userSearchDto);
    }

    @PostMapping
    @ApiOperation("新增人员")
    public Boolean addUser(@RequestBody UserDto userDto){
        userService.addUser(userDto);
        return true;
    }

    @PutMapping("/{userId}")
    @ApiOperation("修改员工")
    public Boolean updateUser(@PathVariable Integer userId,@RequestBody UserDto userDto){
        userService.updateUser(userId,userDto);
        return true;
    }

    @DeleteMapping("/{userId}")
    @ApiOperation("删除员工")
    public Boolean delUser(@PathVariable Integer userId){
        userService.delUser(userId);
        return true;
    }
}
